
/*
 * php_php_guichan.h
 * This file is part of php_guichan extension for PHP
 *
 * Copyright (C) 2012 - likewu
 *
 * php_guichan extension for PHP is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * php_guichan extension for PHP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with php_guichan extension for PHP; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 * 
 * Linking php_guichan extension for PHP statically or dynamically with other modules is 
 * making a combined work based on php_guichan extension for PHP. Thus, the
 * terms and conditions of the GNU General Public License cover the
 * whole combination.
 *
 * In addition, as a special exception, the copyright holders of 
 * php_guichan extension for PHP give you permission to combine php_guichan extension for PHP with free
 * software programs or libraries that are released under the GNU 
 * LGPL and PHP License, and with code included in the standard 
 * release of libSDL under the LGPL 
 * (or modified versions of such code, with unchanged license), and
 * libraries and with code included in the standard release of PHP under
 * the PHP License.
 *
 * You may copy and distribute such a system following the terms 
 * of the GNU GPL for @extname and the licenses 
 * of the other code concerned {, provided that you include the source 
 * code of that other code when and as the GNU GPL requires distribution
 * of source code}.
 * 
 * Note that people who make modified versions of php_guichan extension for PHP are not 
 * obligated to grant this special exception for their modified 
 * versions; it is their choice whether to do so. The GNU General 
 * Public License gives permission to release a modified version 
 * without this exception; this exception also makes it possible to 
 * release a modified version which carries forward this exception.
 */
		
#ifndef PHP_GUICHAN_H
/* Prevent double inclusion */
#define PHP_GUICHAN_H

/* Define Extension Properties */
#define PHP_GUICHAN_EXTNAME   "guichan"
#define PHP_GUICHAN_EXTVER    "1.0"

/* Import configure options
   when building outside of
   the PHP source tree */

/* Include PHP Standard Header */
//#ifdef WIN32
//#include <math.h>
//#endif
//extern "C" {
#include "php.h"
#include "ext/standard/info.h"
//}

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

//#include "SDL.h"

#ifdef HAVE_SDL_IMAGE
#include "SDL_image.h"
#endif

#ifdef HAVE_SDL_TTF
#include "SDL_ttf.h"
#endif

#ifdef HAVE_SDL_GFX
#include "SDL_gfxPrimitives.h"
#include "SDL_framerate.h"
#endif
	

/* Define the entry point symbol
 * Zend will use when loading this module
 */

PHP_MINIT_FUNCTION(guichan);
PHP_MSHUTDOWN_FUNCTION(guichan);
PHP_RINIT_FUNCTION(guichan);
PHP_RSHUTDOWN_FUNCTION(guichan);
PHP_MINFO_FUNCTION(guichan);

/*******************************
 * Function Declarations
 *******************************/
PHP_FUNCTION(sdl_warpmouse);
PHP_FUNCTION(sdl_createcursor);
PHP_FUNCTION(sdl_freecursor);
PHP_FUNCTION(sdl_setcursor);
PHP_FUNCTION(sdl_getcursor);
PHP_FUNCTION(sdl_showcursor);
PHP_FUNCTION(sdl_gl_loadlibrary);
PHP_FUNCTION(sdl_gl_getprocaddress);
PHP_FUNCTION(sdl_gl_getattribute);
PHP_FUNCTION(sdl_gl_setattribute);
PHP_FUNCTION(sdl_gl_swapbuffers);
PHP_FUNCTION(sdl_createyuvoverlay);
PHP_FUNCTION(sdl_lockyuvoverlay);
PHP_FUNCTION(sdl_unlockyuvoverlay);
PHP_FUNCTION(sdl_displayyuvoverlay);
PHP_FUNCTION(sdl_freeyuvoverlay);
PHP_FUNCTION(sdl_wm_setcaption);
PHP_FUNCTION(sdl_wm_getcaption);
PHP_FUNCTION(sdl_wm_seticon);
PHP_FUNCTION(sdl_wm_iconifywindow);
PHP_FUNCTION(sdl_wm_togglefullscreen);
PHP_FUNCTION(sdl_wm_grabinput);
PHP_FUNCTION(sdl_button);
PHP_FUNCTION(sdl_pumpevents);
PHP_FUNCTION(sdl_pollevent);
PHP_FUNCTION(sdl_waitevent);
PHP_FUNCTION(sdl_peepevents);
PHP_FUNCTION(sdl_pushevent);
PHP_FUNCTION(sdl_seteventfilter);
PHP_FUNCTION(sdl_geteventfilter);
PHP_FUNCTION(sdl_eventstate);
PHP_FUNCTION(sdl_getkeystate);
PHP_FUNCTION(sdl_getmodstate);
PHP_FUNCTION(sdl_setmodstate);
PHP_FUNCTION(sdl_getkeyname);
PHP_FUNCTION(sdl_enableunicode);
PHP_FUNCTION(sdl_enablekeyrepeat);
PHP_FUNCTION(sdl_getmousestate);
PHP_FUNCTION(sdl_getrelativemousestate);
PHP_FUNCTION(sdl_getappstate);
PHP_FUNCTION(sdl_numjoysticks);
PHP_FUNCTION(sdl_joystickname);
PHP_FUNCTION(sdl_joystickopen);
PHP_FUNCTION(sdl_joystickopened);
PHP_FUNCTION(sdl_joystickindex);
PHP_FUNCTION(sdl_joysticknumaxes);
PHP_FUNCTION(sdl_joysticknumballs);
PHP_FUNCTION(sdl_joysticknumhats);
PHP_FUNCTION(sdl_joysticknumbuttons);
PHP_FUNCTION(sdl_joystickupdate);
PHP_FUNCTION(sdl_joystickeventstate);
PHP_FUNCTION(sdl_joystickgetaxis);
PHP_FUNCTION(sdl_joystickgethat);
PHP_FUNCTION(sdl_joystickgetball);
PHP_FUNCTION(sdl_joystickgetbutton);
PHP_FUNCTION(sdl_joystickclose);
PHP_FUNCTION(sdl_cd_indrive);
PHP_FUNCTION(sdl_frames_to_msf);
PHP_FUNCTION(sdl_msf_to_frames);
PHP_FUNCTION(sdl_cdnumdrives);
PHP_FUNCTION(sdl_cdname);
PHP_FUNCTION(sdl_cdopen);
PHP_FUNCTION(sdl_cdstatus);
PHP_FUNCTION(sdl_cdplay);
PHP_FUNCTION(sdl_cdplaytracks);
PHP_FUNCTION(sdl_cdpause);
PHP_FUNCTION(sdl_cdresume);
PHP_FUNCTION(sdl_cdstop);
PHP_FUNCTION(sdl_cdeject);
PHP_FUNCTION(sdl_cdclose);
PHP_FUNCTION(sdl_createmutex);
PHP_FUNCTION(sdl_destroymutex);
PHP_FUNCTION(sdl_mutexp);
PHP_FUNCTION(sdl_mutexv);
PHP_FUNCTION(sdl_getticks);
PHP_FUNCTION(sdl_delay);
PHP_FUNCTION(sdl_addtimer);
PHP_FUNCTION(sdl_removetimer);
PHP_FUNCTION(sdl_init);
PHP_FUNCTION(sdl_initsubsystem);
PHP_FUNCTION(sdl_quitsubsystem);
PHP_FUNCTION(sdl_wasinit);
PHP_FUNCTION(sdl_quit);
PHP_FUNCTION(sdl_geterror);
PHP_FUNCTION(sdl_mustlock);
PHP_FUNCTION(sdl_getvideosurface);
PHP_FUNCTION(sdl_getvideoinfo);
PHP_FUNCTION(sdl_videodrivername);
PHP_FUNCTION(sdl_listmodes);
PHP_FUNCTION(sdl_videomodeok);
PHP_FUNCTION(sdl_setvideomode);
PHP_FUNCTION(sdl_updaterect);
PHP_FUNCTION(sdl_updaterects);
PHP_FUNCTION(sdl_flip);
PHP_FUNCTION(sdl_setcolors);
PHP_FUNCTION(sdl_setpalette);
PHP_FUNCTION(sdl_setgamma);
PHP_FUNCTION(sdl_getgammaramp);
PHP_FUNCTION(sdl_setgammaramp);
PHP_FUNCTION(sdl_maprgb);
PHP_FUNCTION(sdl_maprgba);
PHP_FUNCTION(sdl_getrgb);
PHP_FUNCTION(sdl_getrgba);
PHP_FUNCTION(sdl_creatergbsurface);
PHP_FUNCTION(sdl_creatergbsurfacefrom);
PHP_FUNCTION(sdl_freesurface);
PHP_FUNCTION(sdl_locksurface);
PHP_FUNCTION(sdl_unlocksurface);
PHP_FUNCTION(sdl_loadbmp);
PHP_FUNCTION(sdl_savebmp);
PHP_FUNCTION(sdl_setcolorkey);
PHP_FUNCTION(sdl_setalpha);
PHP_FUNCTION(sdl_setcliprect);
PHP_FUNCTION(sdl_getcliprect);
PHP_FUNCTION(sdl_convertsurface);
PHP_FUNCTION(sdl_blitsurface);
PHP_FUNCTION(sdl_fillrect);
PHP_FUNCTION(sdl_displayformat);
PHP_FUNCTION(sdl_displayformatalpha);
PHP_FUNCTION(guichan_init);
PHP_FUNCTION(guichan_newgraphics);
PHP_FUNCTION(guichan_setgraphics);
PHP_FUNCTION(guichan_newinput);
PHP_FUNCTION(guichan_pushinput);
PHP_FUNCTION(guichan_newcontainer);
PHP_FUNCTION(guichan_newimagefont);
PHP_FUNCTION(guichan_setglobalfont);
PHP_FUNCTION(guichan_newlabel);
PHP_FUNCTION(guichan_newbutton);
PHP_FUNCTION(guichan_newtextbox);
PHP_FUNCTION(guichan_newtextfield);
PHP_FUNCTION(guichan_logic);
PHP_FUNCTION(guichan_draw);
PHP_FUNCTION(guichan_quit);
PHP_FUNCTION(guichan_test);
#ifdef HAVE_SDL_IMAGE
PHP_FUNCTION(img_load);
#endif
#ifdef HAVE_SDL_GFX
PHP_FUNCTION(sdlgfx_pixelColor);
PHP_FUNCTION(sdlgfx_pixelRGBA);
PHP_FUNCTION(sdlgfx_hlineColor);
PHP_FUNCTION(sdlgfx_hlineRGBA);
PHP_FUNCTION(sdlgfx_vlineColor);
PHP_FUNCTION(sdlgfx_vlineRGBA);
PHP_FUNCTION(sdlgfx_rectangleColor);
PHP_FUNCTION(sdlgfx_rectangleRGBA);
PHP_FUNCTION(sdlgfx_boxColor);
PHP_FUNCTION(sdlgfx_boxRGBA);
PHP_FUNCTION(sdlgfx_lineColor);
PHP_FUNCTION(sdlgfx_lineRGBA);
PHP_FUNCTION(sdlgfx_aalineColor);
PHP_FUNCTION(sdlgfx_aalineRGBA);
PHP_FUNCTION(sdlgfx_circleColor);
PHP_FUNCTION(sdlgfx_circleRGBA);
PHP_FUNCTION(sdlgfx_aacircleColor);
PHP_FUNCTION(sdlgfx_aacircleRGBA);
PHP_FUNCTION(sdlgfx_filledCircleColor);
PHP_FUNCTION(sdlgfx_filledCircleRGBA);
PHP_FUNCTION(sdlgfx_ellipseColor);
PHP_FUNCTION(sdlgfx_ellipseRGBA);
PHP_FUNCTION(sdlgfx_aaellipseColor);
PHP_FUNCTION(sdlgfx_aaellipseRGBA);
PHP_FUNCTION(sdlgfx_filledEllipseColor);
PHP_FUNCTION(sdlgfx_filledEllipseRGBA);
PHP_FUNCTION(sdlgfx_pieColor);
PHP_FUNCTION(sdlgfx_pieRGBA);
PHP_FUNCTION(sdlgfx_filledPieColor);
PHP_FUNCTION(sdlgfx_filledPieRGBA);
PHP_FUNCTION(sdlgfx_trigonColor);
PHP_FUNCTION(sdlgfx_trigonRGBA);
PHP_FUNCTION(sdlgfx_aatrigonColor);
PHP_FUNCTION(sdlgfx_aatrigonRGBA);
PHP_FUNCTION(sdlgfx_filledTrigonColor);
PHP_FUNCTION(sdlgfx_filledTrigonRGBA);
PHP_FUNCTION(sdlgfx_polygonColor);
PHP_FUNCTION(sdlgfx_polygonRGBA);
PHP_FUNCTION(sdlgfx_aapolygonColor);
PHP_FUNCTION(sdlgfx_aapolygonRGBA);
PHP_FUNCTION(sdlgfx_filledPolygonColor);
PHP_FUNCTION(sdlgfx_filledPolygonRGBA);
PHP_FUNCTION(sdlgfx_bezierColor);
PHP_FUNCTION(sdlgfx_bezierRGBA);
PHP_FUNCTION(sdlgfx_characterColor);
PHP_FUNCTION(sdlgfx_characterRGBA);
PHP_FUNCTION(sdlgfx_stringColor);
PHP_FUNCTION(sdlgfx_stringRGBA);
PHP_FUNCTION(sdlgfx_gfxPrimitivesSetFont);
PHP_FUNCTION(sdlgfx_rotozoomSurface);
PHP_FUNCTION(sdlgfx_rotozoomSurfaceXY);
PHP_FUNCTION(sdlgfx_zoomSurface);
PHP_FUNCTION(sdlgfx_initFramerate);
PHP_FUNCTION(sdlgfx_setFramerate);
PHP_FUNCTION(sdlgfx_getFramerate);
PHP_FUNCTION(sdlgfx_framerateDelay);
#endif
#ifdef HAVE_SDL_TTF
PHP_FUNCTION(sdlttf_Init);
PHP_FUNCTION(sdlttf_Quit);
PHP_FUNCTION(sdlttf_WasInit);
PHP_FUNCTION(sdlttf_OpenFont);
PHP_FUNCTION(sdlttf_OpenFontIndex);
PHP_FUNCTION(sdlttf_OpenFontRW);
PHP_FUNCTION(sdlttf_OpenFontIndexRW);
PHP_FUNCTION(sdlttf_GetFontStyle);
PHP_FUNCTION(sdlttf_SetFontStyle);
PHP_FUNCTION(sdlttf_FontHeight);
PHP_FUNCTION(sdlttf_FontAscent);
PHP_FUNCTION(sdlttf_FontDescent);
PHP_FUNCTION(sdlttf_FontLineSkip);
PHP_FUNCTION(sdlttf_FontFaces);
PHP_FUNCTION(sdlttf_FontFaceIsFixedWidth);
PHP_FUNCTION(sdlttf_FontFaceFamilyName);
PHP_FUNCTION(sdlttf_FontFaceStyleName);
PHP_FUNCTION(sdlttf_GlyphMetrics);
PHP_FUNCTION(sdlttf_SizeText);
PHP_FUNCTION(sdlttf_SizeUTF8);
PHP_FUNCTION(sdlttf_SizeUNICODE);
PHP_FUNCTION(sdlttf_RenderText_Solid);
PHP_FUNCTION(sdlttf_RenderUTF8_Solid);
PHP_FUNCTION(sdlttf_RenderUNICODE_Solid);
PHP_FUNCTION(sdlttf_RenderGlyph_Solid);
PHP_FUNCTION(sdlttf_RenderText_Shaded);
PHP_FUNCTION(sdlttf_RenderUTF8_Shaded);
PHP_FUNCTION(sdlttf_RenderUNICODE_Shaded);
PHP_FUNCTION(sdlttf_RenderGlyph_Shaded);
PHP_FUNCTION(sdlttf_RenderText_Blended);
PHP_FUNCTION(sdlttf_RenderUTF8_Blended);
PHP_FUNCTION(sdlttf_RenderUNICODE_Blended);
PHP_FUNCTION(sdlttf_RenderGlyph_Blended);
PHP_FUNCTION(sdlttf_CloseFont);
#endif

/*******************************
 * End Function Declarations
 *******************************/


typedef struct {
	zval *callback;
	zval *params;
	Uint32 thread_id;
	SDL_TimerID timer_id;
} php_sdl_timer;

typedef struct {
	zval *callback;
	zval *params;
} php_callback;

static int getArrayValueByIndex(zval array, long index, zval **dest);
	

ZEND_BEGIN_MODULE_GLOBALS(guichan)

		long show_sdl_errors;
	
ZEND_END_MODULE_GLOBALS(guichan)

ZEND_DECLARE_MODULE_GLOBALS(guichan)

#ifdef ZTS
#include "TSRM/TSRM.h"
#define MYGLOBALS(v)    TSRMG(guichan_globals_id, zend_guichan_globals*, v)
#else
#define MYGLOBALS(v)    (guichan_globals.v)
#endif


extern zend_module_entry guichan_module_entry;

#define guichan_module_ptr &guichan_module_entry



#endif /* PHP_SAMPLE_H */